<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>简介 | Math Complex</title>
    <meta name="description" content="简单易用的JavaScript复数扩展数学库">
 
    
    <link rel="preload" href="/math-complex/assets/css/0.styles.dc9a62cc.css" as="style"><link rel="preload" href="/math-complex/assets/js/app.a7e80bc5.js" as="script"><link rel="preload" href="/math-complex/assets/js/2.b96ecc85.js" as="script"><link rel="preload" href="/math-complex/assets/js/11.aa6e74d4.js" as="script"><link rel="prefetch" href="/math-complex/assets/js/10.e877db03.js"><link rel="prefetch" href="/math-complex/assets/js/12.ef27bf30.js"><link rel="prefetch" href="/math-complex/assets/js/13.6d5e4273.js"><link rel="prefetch" href="/math-complex/assets/js/3.3a2d5ce2.js"><link rel="prefetch" href="/math-complex/assets/js/4.5f9aa696.js"><link rel="prefetch" href="/math-complex/assets/js/5.8bdadb5e.js"><link rel="prefetch" href="/math-complex/assets/js/6.0954e40b.js"><link rel="prefetch" href="/math-complex/assets/js/7.30d57aa9.js"><link rel="prefetch" href="/math-complex/assets/js/8.6149196e.js"><link rel="prefetch" href="/math-complex/assets/js/9.6ecdb287.js">
    <link rel="stylesheet" href="/math-complex/assets/css/0.styles.dc9a62cc.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/math-complex/" class="home-link router-link-active"><!----> <span class="site-name">Math Complex</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/math-complex/" class="nav-link">
  主页
</a></div><div class="nav-item"><a href="/math-complex/guide/" class="nav-link router-link-exact-active router-link-active">
  入门指南
</a></div><div class="nav-item"><a href="/math-complex/API/" class="nav-link">
  API
</a></div><div class="nav-item"><a href="/math-complex/appendix/" class="nav-link">
  附录
</a></div><div class="nav-item"><a href="https://github.com/shawroger/math-complex" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Github
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/math-complex/" class="nav-link">
  主页
</a></div><div class="nav-item"><a href="/math-complex/guide/" class="nav-link router-link-exact-active router-link-active">
  入门指南
</a></div><div class="nav-item"><a href="/math-complex/API/" class="nav-link">
  API
</a></div><div class="nav-item"><a href="/math-complex/appendix/" class="nav-link">
  附录
</a></div><div class="nav-item"><a href="https://github.com/shawroger/math-complex" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Github
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>入门指南</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/math-complex/guide/" class="active sidebar-link">简介</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/math-complex/guide/#工具定位" class="sidebar-link">工具定位</a></li><li class="sidebar-sub-header"><a href="/math-complex/guide/#基础功能" class="sidebar-link">基础功能</a></li><li class="sidebar-sub-header"><a href="/math-complex/guide/#特性" class="sidebar-link">特性</a></li></ul></li><li><a href="/math-complex/guide/start.html" class="sidebar-link">快速开始</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="简介"><a href="#简介" class="header-anchor">#</a> 简介</h1> <h2 id="工具定位"><a href="#工具定位" class="header-anchor">#</a> 工具定位</h2> <p>Math Complex 是一个采用 TypeScript 编写的 JavaScript 扩展数学库，它扩展了Math数学类的一些方法，让 JavaScript 支持复数计算。</p> <h2 id="基础功能"><a href="#基础功能" class="header-anchor">#</a> 基础功能</h2> <ul><li>扩展了复数类</li> <li>实现了复数类的四则、乘方开方运算</li> <li>扩充了辐角、指数转换计算</li> <li>通过 <strong>Reflect</strong> 静态类实现函数式</li> <li>函数式对原生 <strong>number</strong> 类型兼容</li></ul> <h2 id="特性"><a href="#特性" class="header-anchor">#</a> 特性</h2> <ul><li>所有操作都是返回新的 Complex Number 对象</li></ul> <div class="language-javascript extra-class"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> define <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;math-complex&quot;</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> z1 <span class="token operator">=</span> <span class="token function">define</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// z1 = 3 + 4i</span>
<span class="token keyword">const</span> z2 <span class="token operator">=</span> z1<span class="token punctuation">.</span><span class="token function">contrary</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// z2 = -z1 = 3 - 4i</span>
z1<span class="token punctuation">.</span>imaginary <span class="token operator">===</span> <span class="token number">4</span> <span class="token comment">// true, z1本身从未改变</span>
</code></pre></div><ul><li>支持链式操作（严格从左至右执行）</li></ul> <div class="language-javascript extra-class"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> define <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;math-complex&quot;</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> z1 <span class="token operator">=</span> <span class="token function">define</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> z2 <span class="token operator">=</span> <span class="token function">define</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> z3 <span class="token operator">=</span> z1<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>z2<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">mult</span><span class="token punctuation">(</span>z1<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// z3  = (z1 + z2)*z1</span>
</code></pre></div><ul><li>支持Reflect函数式操作</li></ul> <div class="language-javascript extra-class"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> define<span class="token punctuation">,</span> ComplexReflect <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;math-complex&quot;</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> z1 <span class="token operator">=</span> <span class="token function">define</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> z2 <span class="token operator">=</span> <span class="token function">define</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// z3 = z1 + z2 + z1 + z2 +z1</span>
<span class="token keyword">const</span> z3 <span class="token operator">=</span> ComplexReflect<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>z1<span class="token punctuation">,</span> z2<span class="token punctuation">,</span> z1<span class="token punctuation">,</span> z2<span class="token punctuation">,</span> z1<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><!----> <span class="next"><a href="/math-complex/guide/start.html">
        快速开始
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/math-complex/assets/js/app.a7e80bc5.js" defer></script><script src="/math-complex/assets/js/2.b96ecc85.js" defer></script><script src="/math-complex/assets/js/11.aa6e74d4.js" defer></script>
  </body>
</html>
